#!/usr/bin/make -f

include /usr/share/cdbs/1/class/ant.mk
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk

JAVA_HOME := /usr/lib/jvm/java-1.5.0-sun
DEB_JARS  := /usr/share/java/hsqldb.jar

DEB_ANT_BUILD_TARGET = build-dir
DEB_ANT_INSTALL_TARGET = install
DEB_ANT_CLEAN_TARGET = clean
DEB_ANT_ARGS += -Dprefix=/usr -Ddestdir=$(DEB_DESTDIR)

makebuilddir::
	@if [ -f *.jar ]; then \
		echo 'The *.jar file must be removed from the *.orig.tar.gz.'; \
	        exit 1; \
	fi	

IMAGE_SRCDIR  := entagged/entagged-build-resources/image
IMAGE_DESTDIR := $(DEB_DESTDIR)/usr/share/icons/hicolor
install/entagged::
	dh_link /usr/share/java/entagged-tageditor-$(DEB_UPSTREAM_VERSION).jar \
	  /usr/share/java/entagged-tageditor.jar
	install -d  $(IMAGE_DESTDIR)/32x32/apps
	install -m 644 $(IMAGE_SRCDIR)/entagged-32x32.png \
	  $(IMAGE_DESTDIR)/32x32/apps/entagged.png
	install -d  $(IMAGE_DESTDIR)/128x128/apps
	install -m 644 $(IMAGE_SRCDIR)/entagged-128x128.png \
	  $(IMAGE_DESTDIR)/128x128/apps/entagged.png

SF_PROJECT  := http://puzzle.dl.sourceforge.net/sourceforge/entagged
ORIG_FILE   := entagged-tageditor-$(DEB_UPSTREAM_VERSION).tar.gz
DEBIAN_FILE := entagged_$(DEB_UPSTREAM_VERSION).orig.tar.gz
get-orig-source:
	wget -c $(SF_PROJECT)/$(ORIG_FILE)
	mkdir -p orig.dir
	tar -x -f $(ORIG_FILE)   -z -C orig.dir --exclude '*.jar'
	tar -c -f $(DEBIAN_FILE) -z -C orig.dir .
	$(RM) -r $(ORIG_FILE) orig.dir

